package com.jinzecloud.reportapproval.controller;
import com.jinzecloud.reportapproval.constant.AdminSwaggerTagConst;
import com.jinzecloud.reportapproval.form.RoleAddForm;
import com.jinzecloud.reportapproval.form.RoleUpdateForm;
import com.jinzecloud.reportapproval.service.RoleService;
import com.jinzecloud.reportapproval.utils.R;
import com.jinzecloud.reportapproval.vo.RoleVO;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
角色
 */
@RestController
@CrossOrigin
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_ROLE)
@Api(tags = "角色管理",value = "角色管理")
public class RoleController {

    @Resource
    private RoleService roleService;

    @Operation(summary = "添加角色")
    @PostMapping("/role/add")
//    @SaCheckPermission("system:role:add")
    public R addRole(@Valid @RequestBody RoleAddForm roleAddForm) {
        return roleService.addRole(roleAddForm);
    }

    @Operation(summary = "删除角色")
    @GetMapping("/role/delete/{roleId}")
//    @SaCheckPermission("system:role:delete")
    public R deleteRole(@PathVariable Long roleId) {
        return roleService.deleteRole(roleId);
    }

    @Operation(summary = "更新角色")
    @PostMapping("/role/update")
//    @SaCheckPermission("system:role:update")
    public R updateRole(@Valid @RequestBody RoleUpdateForm roleUpdateDTO) {
        return roleService.updateRole(roleUpdateDTO);
    }

    @Operation(summary = "获取角色数据")
    @GetMapping("/role/get/{roleId}")
    public R<RoleVO> getRole(@PathVariable("roleId") Long roleId) {
        return roleService.getRoleById(roleId);
    }

    @Operation(summary = "获取所有角色")
    @GetMapping("/role/getAll")
    public R getAllRole() {
        return roleService.getAllRole();
    }


}
